package exam.db.dao;

import java.util.List;

import exam.db.entity.TQuestionEntity;
import exam.db.entity.name.TQuestionEntityNames;
import exam.driver.jdbc.StatementSql;
import exam.driver.jdbc.WhereComplex;

/**
 * <p>TExaminationDao</p>
 * <p>Thực thi các truy vấn cho TQuestionEntity</p>
 * @author PHONGTN
 * @version 19/4/2012
 */
public class TQuestionDao extends AbstractDao<TQuestionEntity>{
	/**
	 * Constructor
	 */
	public TQuestionDao() {
		super(TQuestionEntity.class);
	}
	/**
	 * selectAll:TQuestionDao
	 * @return
	 */
	public List<TQuestionEntity> selectAll() {
		return super.selectAll(
				TQuestionEntity.class,
				new StatementSql()
					.select()
					.from(TQuestionEntityNames.TABLE_NAME)
					.toString()
				);
	}
	/**
	 * selectByPk:TQuestionDao
	 * @param pk
	 * @return
	 */
	public TQuestionEntity selectByPk(Integer pk) {
		return super.selectByPk(
				TQuestionEntity.class,
				new StatementSql()
					.select()
					.from(TQuestionEntityNames.TABLE_NAME)
					.where(
						new WhereComplex()
							.eq(TQuestionEntityNames.QUESTION_ID, pk))
					.toString());
	}
	/**
	 * deleteByPk:TQuestionDao
	 * @param arrayPk
	 * @return
	 */
	public List<Integer> deleteByPk(int[] arrayPk) {
		return super.deleteByPk(
				new StatementSql()
					.delete()
					.from(TQuestionEntityNames.TABLE_NAME)
					.where(
						new WhereComplex()
							.eq(TQuestionEntityNames.QUESTION_ID))
					.toString(), arrayPk);
	}
	/**
	 * insertByFile:TQuestionDao
	 * @param user
	 * @return
	 */
	public int insertByFile(TQuestionEntity question) {
		String sqlFile = "src/exam/db/dao/sql/TQuestionEntity_insert.sql";
		return super.insertBySqlFile(question, sqlFile);
	}
	/**
	 * updateByFile:TQuestionDao
	 * @param params
	 * @return
	 */
	public int updateByFile(List<Object> params) {
		String sqlFile = "src/exam/db/dao/sql/TQuestionEntity_update.sql";
		return super.updateBySqlFile(sqlFile, params);
	}
}
